<template>
  <div class="ui-form-group" :class="[{'is-divided': divided}]">
    <div class="ui-form-group__head" v-if="label || $slots.label">
      <h5 class="ui-form-group__title">
        <slot name="label">{{label}}</slot>
      </h5>
      <div class="ui-form-group__toolbar" v-if="$slots.toolbar">
        <slot name="toolbar"></slot>
      </div>
    </div>
    <div class="ui-form-group__body">
      <slot></slot>
    </div>
  </div>
</template>
<script>
export default {
  name: 'UiFormGroup',
  props: {
    label: {
      type: String
    },
    divided: {
      type: Boolean,
      default: false
    }
  }
}
</script>
<style lang="less">
.ui-form-group{
  &.is-divided{
    border-bottom: 1px solid #eee;
    padding-bottom: 12px;
    &:last-child{
      border-bottom: initial;
      padding-bottom: initial;
      margin-bottom: initial;
    }
  }
  &:not(:last-child) {
    margin-bottom: 12px;
  }
}
.ui-form-group__head{
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  line-height: 32px;
  padding-bottom: 6px;
  padding-top: 12px;
}
.ui-form-group__title{
  font-weight: bold;
  font-size: 14px;
  margin: 0;
  font-weight: bold;
  display: inline-block;
  cursor: pointer;
}
.ui-form-group__body{
  &:after{
    content: '';
    display: block;
    clear: both;
  }
}
</style>
